package hapi.mvc;

class ListDisplay<T:Displayable> {
	
	var list:List<Dynamic>;
	var prefix:String;
	
	public function new(it:List<T>, ?prefix:String="") {
		list = new List<Dynamic>();
		for ( d in it) {
			var dynamicView:DynamicView  = new DynamicView();
			var view:View = prefix != null ? new Subview(dynamicView, prefix) : dynamicView;
			d.displayOn(view);
			list.add(dynamicView.getContext());
		}
	}
	
	public function iterator():Iterator <Dynamic> {
		return list.iterator();
	}
}